package Shape;

public class Triangle extends Shape{

    public double length1;
    public double length2;
    public double length3;

    public Triangle(int length1, int length2, int length3) {
        this.length1 = length1;
        this.length2 = length2;
        this.length3 = length3;
    }

    @Override
    public double getOutline() {

        if (length1 + length2 < length3) {
            throw new RuntimeException("非法输入!!!");
        }
        if (length2 + length3 < length1) {
            throw  new RuntimeException("非法输入!!!");
        }
        if (length3 + length1 < length2) {
            throw new RuntimeException("非法输入!!!");
        }

        return length1 + length2 + length3;
    }

    @Override
    public double getArea() {

        if (length1 + length2 < length3) {
            throw new RuntimeException("非法输入!!!");
        }
        if (length2 + length3 < length1) {
            throw  new RuntimeException("非法输入!!!");
        }
        if (length3 + length1 < length2) {
            throw new RuntimeException("非法输入!!!");
        }

        return  (length1 + length2 + length3) / 2 ;
    }
}

